<template>
  <div class="container">
    <div class="main" align="center">
      <div class="inwrap">
        <h3>聚合支付-扫码测试</h3>
        <h5>
          请输入金额: <input type="text" v-model="amount" style="width: 60px;" value="" @change="change"> 元
        </h5>
        <div class="example" >
          <div id="qrcode"></div>
          <div><h3 style="color: red">{{amount}}元</h3></div>
          <div><h4 >请使用支付宝或微信手机客户端扫一扫</h4></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import QRCode from 'qrcodejs2' // 引入qrcode
export default {
  data () {
    return {
      link: 'http://192.168.200.105:8888/pay/goodsOrder/qrCodePay.html?amount=',
      amount: '0.01'
    }
  },
  mounted () {
    this.qrcode()
  },
  methods: {
    // 生成二维码
    qrcode () {
      document.getElementById('qrcode').innerHTML = ''
      let qrcode = new QRCode('qrcode', {
        width: 200,
        height: 200,
        text: this.link + (this.amount * 100)// 二维码地址
      })
    },
    change () {
      this.qrcode()
    }
  }
}
</script>
